package com.cy.pj.common.util;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

import javax.servlet.http.HttpServletRequest;

public class PageUtil {
    public static  <E> Page<Object> startPage(/**第一种:HttpServletRequest request*/){
//        第二种：获取request
//        ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
//        HttpServletRequest request =requestAttributes.getRequest();

        HttpServletRequest request = ServletUtil.getRequest();
        //获取当前页面大小(页面显示的条数)
        String pageSizeStr = request.getParameter("pageSize");
        //获取当前页码值
        String pageCurrentStr = request.getParameter("pageCurrent");
        Integer pageCurrent = StringUtil.isEmpty(pageCurrentStr)?1:Integer.parseInt(pageCurrentStr);
        Integer pageSize = StringUtil.isEmpty(pageSizeStr)?5:Integer.parseInt(pageSizeStr);
//       启动分页查询
       return   PageHelper.startPage(pageCurrent,pageSize);


    }
}
